package com.usian.wemedia.controller.v1;

import com.usian.apis.media.WmMaterialControllerApis;
import com.usian.common.wemedia.WemediaContans;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.media.dtos.WmMaterialDto;
import com.usian.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * Auther：DONG on 2021/11/7
 **/
@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController implements WmMaterialControllerApis {
    @Autowired
    private WmMaterialService wmMaterialService;

    @Override
    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(MultipartFile multipartFile) {

        return wmMaterialService.uploadPicture(multipartFile);
    }

    @Override
    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmMaterialDto dto) {

        return wmMaterialService.findList(dto);
    }

    @Override
    @GetMapping("/del_picture/{id}")
    public ResponseResult delWmMaterial(@PathVariable Integer id) {



        return wmMaterialService.delWmMaterial(id);
    }

    @Override
    @GetMapping("/collect/{id}")
    public ResponseResult collectWmMaterial(@PathVariable Integer id) {
        return wmMaterialService.collect(id, WemediaContans.COLLECT_MATERIAL);
    }

    @Override
    @GetMapping("/cancel_collect/{id}")
    public ResponseResult cencelcollctWmMaterial(@PathVariable Integer id) {
        return wmMaterialService.collect(id,WemediaContans.CANCEL_COLLECT_MATERIAL);
    }
}
